package com.work.straighttalk.model;

import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.provider.ContactsContract;
import android.text.TextUtils;

import com.work.straighttalk.R;
import com.work.straighttalk.app.StraightTalk;
import com.work.straighttalk.bean.Contact;

import com.work.straighttalk.model.i.LoadDBDataMI;
import com.work.straighttalk.presenter.i.OnLoadFinishedListener;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * 本model实现用于获取联系人列表
 * Created by 朱相卿 on 16/3/3.
 */
public class ContactsDBDataMImpl implements LoadDBDataMI<List<Contact>> {
    private ContactProvider provider;

    public ContactsDBDataMImpl() {
        provider = new ContactProvider();
    }

    private static String getSortKey(String str) {
        String key = str.substring(0, 1).toUpperCase();
        if (key.matches("[A-Z]")) {
            return key;
        }
        return "#";
    }


    @Override
    public void loadData(Uri uri, final OnLoadFinishedListener<List<Contact>> listener) {
        provider.getContacts(uri, new ContactProvider.ContactCallBack() {
            @Override
            public void onSuccess(List<Contact> contacts) {
                listener.onLoadSuccess(contacts);
            }

            @Override
            public void onError() {

            }
        });
    }


    @Override
    public void clear() {

    }

}
